//
//  NSString+Contains.m

//

#import "NSString+Contains.h"
#import "NSObject+Add.h"

@implementation NSString (Contains)

- (BOOL)myContainsString:(NSString*)other {
    NSRange range = [self rangeOfString:other];
    return range.length != 0;
}

-(BOOL)isEqualString:(NSString *)str{
    if (self==nil || [self isEqual:[NSNull null]]) {
        return NO;
    }
    if (str==nil || [str isEqual:[NSNull null]]) {
        return NO;
    }
//    NSRange range = [self rangeOfString:str];
//    if (range.location == 0&&range.length == self.length) {
//        return YES;
//    }
    if ([self isEqualToString:str]) {
        return YES;
    }
    
    return NO;
}

- (NSString *)URLEncodedString{
    NSString *encodedString = (NSString *) CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                            (CFStringRef)self,
                                            (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]",
                                            NULL,
                                            kCFStringEncodingUTF8));
    return encodedString;
}
/**
 *  @author zhao, 16-05-19 14:05:55
 *
 *  是否以字母开始
 *
 *  @return <#return value description#>
 */
-(BOOL)isLetterBegin{
    if (![self isNotEmpty]) {
        return NO;
    }
    char a = [self characterAtIndex:0];
    if ((a>64&&a<91)||(a>96&&a<123)) {
        return YES;
    }
    return NO;
}

@end
